﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public class DbHelper
    {
        private static readonly string Bule = "server =.;database=Bank;uid =sa;pwd=123456;";
        //连库
        public static DataTable GetDataTable (string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql, Bule);
            DataTable data = new DataTable();
            adapter.Fill(data);
            return data;
        }
        //连表
        public static int AddOrData(string sql)
        {
            SqlConnection connection = new SqlConnection(Bule);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            var get = command.ExecuteNonQuery();
            connection.Close();
            return get;
        }
    }
}